import { IPSSysBIAggColumn } from './ipssys-biagg-column';
import { IPSSysBIAggTable } from './ipssys-biagg-table';
import { IPSSysBICube } from './ipssys-bicube';
import { IPSSysBIScheme } from './ipssys-bischeme';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEDataQuery } from '../dataentity/ds/ipsdedata-query';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysBIAggTableImpl extends PSModelObjectImpl implements IPSSysBIAggTable {
  protected allpssysbiaggcolumns: IPSSysBIAggColumn[] | null = null;

  getAllPSSysBIAggColumns(): IPSSysBIAggColumn[] | null {
    if (this.allpssysbiaggcolumns == null) {
      this.allpssysbiaggcolumns = this.fillChildListModel(this.M.getAllPSSysBIAggColumns, 'bi.IPSSysBIAggColumn') as IPSSysBIAggColumn[];
    }
    return this.allpssysbiaggcolumns;
  }

  get allPSSysBIAggColumns(): IPSSysBIAggColumn[] | null {
    return this.getAllPSSysBIAggColumns();
  }

  findPSSysBIAggColumn(objKey: any): IPSSysBIAggColumn | null {
    return this.getPSModel5('bi.IPSSysBIAggColumn', this.getAllPSSysBIAggColumns(), objKey) as IPSSysBIAggColumn;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdedataquery: IPSDEDataQuery | null = null;

  getPSDEDataQuery(): IPSDEDataQuery | null {
    if (this.psdedataquery != null) return this.psdedataquery;
    const value = this.M.getPSDEDataQuery;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.psdedataquery = ipsdataentity.findPSDEDataQuery(value);
    }
    return this.psdedataquery;
  }

  get psDEDataQuery(): IPSDEDataQuery | null {
    return this.getPSDEDataQuery();
  }

  getPSDEDataQueryMust(): IPSDEDataQuery {
    const value = this.getPSDEDataQuery();
    if (value == null) {
      throw new Error('未指定数据查询');
    }
    return value;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体');
    }
    return value;
  }

  protected pssysbicube: IPSSysBICube | null = null;

  getPSSysBICube(): IPSSysBICube | null {
    if (this.pssysbicube != null) return this.pssysbicube;
    const value = this.M.getPSSysBICube;
    if (value == null) {
      return null;
    }
    const ipssysbischeme = this.getParentPSModelObject('bi.IPSSysBIScheme') as IPSSysBIScheme;
    if (ipssysbischeme != null) {
      this.pssysbicube = ipssysbischeme.findPSSysBICube(value);
    }
    return this.pssysbicube;
  }

  get psSysBICube(): IPSSysBICube | null {
    return this.getPSSysBICube();
  }

  getPSSysBICubeMust(): IPSSysBICube {
    const value = this.getPSSysBICube();
    if (value == null) {
      throw new Error('未指定智能报表立方体');
    }
    return value;
  }

  get tableTag(): string {
    return this.M.tableTag;
  }

  get tableTag2(): string {
    return this.M.tableTag2;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysBIAggTableImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'bi.IPSBIAggTable' || cls == 'bi.IPSSysBIAggTable') return true;
    return super.instanceof(cls);
  }
}
